
export const infoOption = {
    cellBtn: true,
    addBtn: false,
    editBtn: false,
    header: false,
    menuWidth: 150,
    column: [
        {
            label: '物料编码',
            prop: 'materialNo',
            minWidth: 100
        },
        { label: '物料名称', prop: 'materialName', minWidth: 100 },
        { label: '内部图号', prop: 'innerDrawingNo', minWidth: 150 },
        {
            label: '规格',
            prop: 'specifications',
            minWidth: 150,
            overHidden: true,
        },
        {
            label: '型号',
            prop: 'model',
            minWidth: 150,
            overHidden: true,
        },
        {
            label: '定额',
            prop: 'quota',
            cell: true,
            maxlength: 8,
            minWidth: 140,
            rules: [
                {
                    required: true,
                    message: '请输入定额',
                    trigger: 'blur',
                },
                // { validator: validateQuota, trigger: 'blur' },
            ],
        },
        {
            label: '计量单位',
            prop: 'unit',
            type: 'select',
            dicData: [],
            span: 12,
        },
        {
            label: '损耗率',
            prop: 'lossRate',
            span: 12,
            cell: true,
            append: '%',
            minWidth: 170,
            rules: [
                {
                    required: true,
                    message: '请输入损耗率',
                    trigger: 'blur',
                },
                // {
                //     pattern: /^(0|[1-9])(\.\d{1,2})?$/,
                //     message: '请输入10以内的正整数或最多两位小数',
                //     trigger: 'blur',
                // },
            ],
        },
        // {
        //   label: '投料工序',
        //   prop: 'prdProcedureId',
        //   cell: true,
        //   type: 'select',
        //   props: {
        //     label: 'procedureName',
        //     value: 'id',
        //   },
        //   dicData: [],
        //   minWidth: 150,
        //   span: 12,
        // },
    ],
}
var validateQuota = (rule, value, callback) => {
    let reg = /^[0-9]*\/+[1-9][0-9]*$/; //分数验证
    let reg1 = /^([0-9]|[1-9][0-9])(\.\d{1,4})?$/; //100以内的整数或最多四位小数验证
    if (value) {
        if (value == '0') {
            callback(new Error('请输入100以内的正整数或最多四位小数，或小于1的分数(如1/2700)'));
        } else if (reg.test(value)) {
            let arr = value.split('/');
            if (arr[0] == 0 || arr[1] == 0 || arr[0] >= arr[1]) {
                callback(new Error('请输入100以内的正整数或最多四位小数，或小于1的分数(如1/2700)'));
            } else {
                callback();
            }
        } else if (!reg.test(value) && !reg1.test(value)) {
            callback(new Error('请输入100以内的正整数或最多四位小数，或小于1的分数(如1/2700)'));
        } else {
            callback();
        }
    } else {
        callback();
    }
};
export const BOMoption = {
    tip: false,
    index: true,
    border: true,
    // menu: false,
    addBtn: false,
    editBtn: false,
    delBtn: false,
    header: false,
    menuWidth: 100,
    dialogWidth: '80%',
    // maxHeight: '300px',
    defaultExpandAll: true,
    column: [
        { label: '顶级产品', prop: 'topProductNo', hide: true, showColumn: false, display: false },
        { label: '上级产品', prop: 'directLeaderNo', hide: true, showColumn: false, display: false },
        {
            label: '产品',
            prop: 'productName',
            disabled: true,
            addDisplay: true,
            editDisplay: false,
            viewDisplay: false,
            hide: true, showColumn: false,
            span: 12,
        },
        {
            label: '物料编码',
            prop: 'materialNo',
            span: 12,
            disabled: true,
            addDisplay: false,
            minWidth: 150,
        },
        {
            label: '物料类型',
            prop: 'materialTypes',
            type: 'cascader',
            dicData: [],
            props: {
                label: 'dictValue',
                value: 'dictKey',
            },
            span: 12,
            disabled: true,
            display: false,
            minWidth: 150,
        },
        {
            label: '物料组',
            prop: 'materialGroupName',
            span: 12,
            disabled: true,
            display: false,
            minWidth: 150,
        },
        {
            label: '物料名称',
            prop: 'materialName',
            span: 12,
            disabled: true,
            addDisplay: false,
            minWidth: 150,
        },
        {
            label: '内部图号',
            prop: 'innerDrawingNo',
            span: 12,
            minWidth: 80,
            overHidden: true,
            disabled: true,
            addDisplay: false,
        },
        {
            label: '规格',
            prop: 'specifications',
            minWidth: 120,
            overHidden: true,
            disabled: true,
            addDisplay: false,
            span: 12,
        },
        {
            label: '型号',
            prop: 'model',
            minWidth: 120,
            overHidden: true,
            disabled: true,
            addDisplay: false,
            span: 12,
        },
        {
            label: '定额',
            prop: 'quota',
            span: 12,
            maxlength: 8,
            minWidth: 70,
            overHidden: true,
            addDisplay: false,
            rules: [
                {
                    required: true,
                    message: '请输入定额',
                    trigger: 'blur',
                },
                { validator: validateQuota, trigger: 'blur' },
            ],
        },
        {
            label: '计量单位',
            prop: 'unit',
            type: 'select',
            dicData: [],
            disabled: true,
            minWidth: 70,
            overHidden: true,
            addDisplay: false,
            span: 12,
        },
        {
            label: '损耗率',
            prop: 'lossRate',
            minWidth: 60,
            span: 12,
            slot: true,
            formslot: true,
            append: '%',
            addDisplay: false,
            rules: [
                {
                    required: true,
                    message: '请输入损耗率',
                    trigger: 'blur',
                },
                {
                    pattern: /^(0|[1-9])(\.\d{1,2})?$/,
                    message: '请输入10以内的正整数或最多两位小数',
                    trigger: 'blur',
                },
            ],
        },
    ],
    group: [
        {
            label: 'BOM组成',
            prop: 'jbxx',
            icon: 'el-icon-edit-outline',
            column: [
                {
                    label: '物料类型',
                    prop: 'materialType',
                    type: 'cascader',
                    hide: true,
                    showColumn: false,
                    viewDisplay: false,
                    span: 7,
                    dicData: [],
                    props: {
                        label: 'dictValue',
                        value: 'dictKey',
                    },
                },
                {
                    label: '物料组',
                    prop: 'materialGroupNo',
                    type: 'select',
                    filterable: true,
                    hide: true,
                    showColumn: false,
                    viewDisplay: false,
                    span: 7,
                    props: {
                        label: 'materialGroupName',
                        value: 'materialGroupNo',
                    },
                    dicData: [],
                },
                {
                    label: '物料',
                    prop: 'bomNo',
                    filterable: true,
                    type: 'select',
                    hide: true,
                    showColumn: false,
                    viewDisplay: false,
                    span: 7,
                    dicData: [],
                },
                {
                    label: '',
                    labelWidth: 0,
                    viewDisplay: false,
                    span: 3,
                    prop: 'addScope',
                    hide: true,
                    formslot: true,
                },
                {
                    labelWidth: 0,
                    label: '',
                    prop: 'infoScope',
                    span: 24,
                    hide: true,
                    formslot: true,
                },
            ],
        },
    ],
}
